package com.special.threademo.concurrency.synchcriozed;

import com.itextpdf.text.log.SysoCounter;

/**
 * Created with IDEA2020.3
 * author:LiuYC
 * DateTime:2021/1/7  13:41
 */
public class MyThreadTest {
    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        Thread thread = new Thread(myThread);
        Thread thread1 = new Thread(myThread);
        thread.start();
        thread1.start();
    }
}

class MyThread implements Runnable {
    int x;

    @Override
    public void run() {
        x = 0;
        while (true) {
            System.out.println("xresult" + x++);
            try {
                Thread.sleep((long) (Math.random() * 1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (x == 30) {
                break;
            }
        }
    }
}

